﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/MasterPage.master" AutoEventWireup="true" CodeFile="Cautare.aspx.cs" Inherits="Pages_Store_Cautare" %>
<%@ Register Src="../WebControls/Product.ascx" TagName="Product" TagPrefix="fns" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
   <%-- <asp:UpdatePanel ID="SearchUpdatePanel" runat="server">
        <ContentTemplate>--%>
            <asp:ListView ID="ProductsRepeter" runat="server" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <fns:Product ID="Product" runat="server" ProductID='<%#Eval("ID") %>' ProductName='<%#Eval("name") %>'
                        ImageUrl='<%#Eval("image_url") %>' Price='<%#Eval("price") %>' OldPrice='<%#Eval("old_price") %>'
                        Rating='<%#Eval("rating") %>' Views='<%#Eval("views") %>' IsPromotion='<%#Eval("is_promotion") %>' />
                </ItemTemplate>
                <LayoutTemplate>
                    <div id="ProductsDisplayPanel" style="clear: both;">
                        <div id="Div1" style="float: left;" runat="server">
                            <div runat="server" id="itemPlaceholder">
                            </div>
                        </div>
                        <div id="Div2" style="float: right" runat="server">
                            <div class="product_pagination">
                                <asp:DataPager ID="ProductsDataPagerBottom" runat="server" PagedControlID="ProductsRepeter"
                                    PageSize="18">
                                    <Fields>
                                        <asp:NextPreviousPagerField PreviousPageText="«" ShowNextPageButton="False" ButtonCssClass="page_nr" />
                                        <asp:NumericPagerField CurrentPageLabelCssClass="page_nr_selected page_nr" NumericButtonCssClass="page_nr"
                                            NextPreviousButtonCssClass="page_nr" />
                                        <asp:NextPreviousPagerField NextPageText="»" ShowPreviousPageButton="False" ButtonCssClass="page_nr" />
                                    </Fields>
                                </asp:DataPager>
                            </div>
                        </div>
                    </div>
                </LayoutTemplate>
                <EmptyDataTemplate>
                    <center>
                        <span>Nu sa gasit nici un produs</span></center>
                </EmptyDataTemplate>
            </asp:ListView>

    <%--    </ContentTemplate>
        <%-- <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Pager" EventName="Command" />
        </Triggers>
    </asp:UpdatePanel>--%>--%>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>" 
        SelectCommand="SELECT Products.ID, Products.price, Products.old_price, Products.views, Products.rating, Images.size_type, Images.image_url, Products.is_promotion, Products.name FROM Images INNER JOIN Products ON Images.ProductID = Products.ID INNER JOIN Product_Categories ON Products.CategoryID = Product_Categories.CategoryID INNER JOIN Brands ON Products.BrandID = Brands.ID WHERE (Products.deleted = 0) AND (Products.is_active = 1) AND (Images.size_type = 'small') OR (LOWER(Products.name) like  '%LOWER(@search)%') OR (LOWER(Brands.brand_name) =  '%LOWER(@search)%') OR (LOWER(Product_Categories.category_name) = '%LOWER(@search)%')">
        <SelectParameters>
            <asp:RouteParameter Name="search" RouteKey="search" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
